<template>
  <div style="padding-top: 5px;" @click="handleClick">
    <transition name="hamburger-fade">
      <img
        v-if="active"
        key="active"
        :src="require('@/assets/images/top2.png')"
        class="hamburger-img"
        alt="menu"
        width="16"
        height="14"
        style="height: 14px; width: 15px;"
      />
      <img
        v-else
        key="inactive"
        :src="require('@/assets/images/top.png')"
        class="hamburger-img"
        alt="menu"
        width="16"
        height="14"
        style="height: 14px; width: 15px;"
      />
    </transition>
  </div>
</template>

<script>
export default {
  name: 'Hamburger',
  props: {
    isActive: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      active: this.isActive
    }
  },
  watch: {
    isActive(val) {
      this.active = val
    }
  },
  methods: {
    handleClick() {
      this.active = !this.active
      this.$emit('toggleClick', this.active)
    }
  }
}
</script>

<style scoped>
.hamburger-fade-enter-active, .hamburger-fade-leave-active {
  transition: opacity 0.25s cubic-bezier(.4,2,.3,1), transform 0.25s cubic-bezier(.4,2,.3,1);
}
.hamburger-fade-enter, .hamburger-fade-leave-to {
  opacity: 0;
  transform: scale(0.8) rotate(-10deg);
}
.hamburger-img {
  display: inline-block;
  vertical-align: middle;
  width: 32px;
  height: 32px;
  cursor: pointer;
}
</style>
